package hz.mobileproject.pda.toolsmanager.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.blankj.utilcode.util.TimeUtils;

import org.xutils.view.annotation.ViewInject;

import java.text.SimpleDateFormat;
import java.util.List;

import hz.mobileproject.pda.R;
import hz.mobileproject.pda.toolsmanager.bean.response.RP_ToolInfo;
import hz.mobileproject.pda.ui.base.BaseCustomAdapter;
import hz.mobileproject.pda.utils.TextViewUtil;

/**
 * Created by Alex on 2018/4/27.
 */

public class AddReportoryAdapter extends BaseCustomAdapter<RP_ToolInfo,AddReportoryAdapter.ViewHolder> {


    private String policeName;

    public AddReportoryAdapter(Context mContext, List<RP_ToolInfo> list) {
        super(mContext, list);
    }

    @Override
    protected int bindView() {
        return R.layout.item_add_reportory;
    }

    @Override
    protected ViewHolder createViewHolder() {
        return new ViewHolder();
    }

    @Override
    protected void bindData(final int position, View convertView, ViewHolder viewHolder) {
        RP_ToolInfo bean = mList.get(position);
        TextViewUtil.setUnderLine(viewHolder.tv_gjlx,bean.getTool_type_name());
        TextViewUtil.setUnderLine(viewHolder.tv_gjmc,bean.getTool_name());
        TextViewUtil.setUnderLine(viewHolder.tv_add_time, TimeUtils.getNowString(new SimpleDateFormat("yyyy-MM-dd")));
        TextViewUtil.setUnderLine(viewHolder.tv_add_person,policeName);

        viewHolder.tv_add_portory_delete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(mOnDelClickListener !=null){
                    mOnDelClickListener.dele(position);
                }
            }
        });

    }

    public void setPoliceName(String police_name) {
        this.policeName = police_name;
    }

    class ViewHolder {
        @ViewInject(R.id.tv_gjlx)
        private TextView tv_gjlx;
        @ViewInject(R.id.tv_gjmc)
        private TextView tv_gjmc;
        @ViewInject(R.id.tv_add_time)
        private TextView tv_add_time;
        @ViewInject(R.id.tv_add_person)
        private TextView tv_add_person;
        @ViewInject(R.id.tv_add_portory_delete)
        private TextView tv_add_portory_delete;

    }

    private onDelClickListener mOnDelClickListener;

    public interface onDelClickListener {
        void dele(int position);
    }

    public void setmOnDelClickListener(onDelClickListener mOnDelClickListener) {
        this.mOnDelClickListener = mOnDelClickListener;
    }
}
